package com.dogdog.UI;

import java.util.List;

import com.dogdog.activity.R;
import com.dogdog.bean.Pet;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PetinfoAdapter extends BaseAdapter {
    
	List<Pet> pets;
	Context c;
	
	public PetinfoAdapter(Context con,List<Pet> pets){
		this.pets=pets;
		this.c=con;
	}
	
	public void setPetData(List<Pet> petdata){
		this.pets=petdata;
	}
	
	@Override
	public int getCount() {
		return pets.size();
	}

	@Override
	public Pet getItem(int position) {
		return pets.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
            convertView = View.inflate(c,
                    R.layout.item_listview_userinfo_pet, null);
            new ViewHolder(convertView);
            ViewHolder holder = (ViewHolder) convertView.getTag();
	        Pet petdata=getItem(position);
	        holder.pet_name.setText(petdata.getName());
	        holder.pet_age.setText(petdata.getAge()+"岁");
	        holder.pet_kind.setText(petdata.getPet_kind());
	        holder.pet_worktime.setText(petdata.getTime());
	        holder.pet_name.setText(petdata.getName());
	        }
	        return convertView;
	}
			
		private class ViewHolder {
	        TextView pet_name;
	        TextView pet_kind;
	        TextView pet_age;
	        TextView pet_worktime;
//	        Bitmap cash;
	        public ViewHolder(View view) {
	            pet_name = (TextView)view.findViewById(
	            		R.id.pet_name);
	            pet_age = (TextView)view.findViewById(
	            		R.id.pet_age);
	            pet_worktime = (TextView)view.findViewById(
	            		R.id.pet_worktime);
	            pet_kind = (TextView)view.findViewById(
	            		R.id.pet_kind);
	            view.setTag(this);        }
	    }

}
